#ifndef CNETWORK_H
#define CNETWORK_H

#include <QObject>
#include <QTcpServer>

#include "../Models/MNetwork.h"

class CNetwork : public QObject
{
    Q_OBJECT
    private:
        MNetwork* m_network;
        QTcpServer *server;

        CNetwork();
        ~CNetwork();

        static CNetwork *singleton;
        static CNetwork *singleton_chat;
        static CNetwork *singleton_gs;

    public:
        static CNetwork *get_instance();
        static CNetwork *get_instance_chat();
        static CNetwork *get_instance_gs();

        MNetwork* get_network();

    signals:
        void is_receiving();
        void is_disconnecting();

        void authentification_ok();
        void authentification_failed();

        void receive_chat(QString);

        void receive_characters();

    public slots:
        void connect(QString hostaname, quint16 port);
        void disconnect();

        void select_action();

        void send(QString message);
        void send(QTcpSocket* socket, QString message);
        QString receive();
        QString receive(QTcpSocket* socket);
};

#endif // CNETWORK_H
